<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = 'D:/kobako/uploads/test/';
$uploadfile = $uploaddir . basename($_FILES['avatar']['name']);

// echo json_encode([
//     "name"
// ])

if (move_uploaded_file($_FILES['avatar']['tmp_name'], $uploadfile)) {
    echo json_encode(["url" => $uploaddir . $uploadfile ],JSON_UNESCAPED_UNICODE);
} else {
    echo json_encode(["url" => "","err" => "上传不成功!" ],JSON_UNESCAPED_UNICODE);
    // echo "Possible file upload attack!\n";
}
// print_r($_FILES);

// print "</pre>";

?>